home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / FifoScheduler.cc < prev    next >
C/C++ Source or Header  |  1990-07-09  |  1KB  |  67 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. // 
  3. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  4. // Copyright (C) 1989 University of Colorado, Boulder, Colorado
  5. // Copyright (C) 1990 University of Colorado, Boulder, Colorado
  6. //
  7. // written by Dirk Grunwald (grunwald@foobar.colorado.edu)
  8. //
  9. #include "Thread.h"
  10. #include "FifoScheduler.h"
  11. #include "stream.h"
  12. #include "assert.h"
  13.  
  14. FifoScheduler::FifoScheduler(int defaultLength, bool xdebug)
  15.     : (xdebug), fifo(defaultLength)
  16. {
  17.     fifo.reSize(defaultLength);
  18. }
  19.  
  20. void
  21. FifoScheduler::add(Thread *t)
  22. {
  23.     fifo.add((AwesimePtr *) &t);
  24. }
  25.  
  26. void
  27. FifoScheduler::add(double , Thread *)
  28. {
  29.     assert2(FALSE, "[FifoScheduler] add(when, thread) not provided");
  30. }
  31.  
  32. Thread *
  33. FifoScheduler::remove()
  34. {
  35.     AwesimeFifoItem item;
  36.     bool removed = fifo.remove(&item);
  37.     Thread *thread = (Thread *) item;
  38.     if ( ! removed ) {
  39.     thread = 0;
  40.     }
  41.     return( thread );
  42. }
  43.  
  44. Thread *
  45. FifoScheduler::remove(Thread *t)
  46. {
  47.     AwesimeFifoItem item = (AwesimeFifoItem) t;
  48.     bool removed = fifo.remove(&item);
  49.     assert2( removed, " Attempted to remove non-existent item");
  50.     return(t);
  51. }
  52.  
  53. bool FifoScheduler::isEmpty()
  54. {
  55.     return(fifo.isEmpty());
  56. }
  57.  
  58. unsigned int FifoScheduler::size()
  59. {
  60.     return(fifo.size());
  61. }
  62.  
  63. void FifoScheduler::classPrintOn(ostream& s)
  64. {
  65.     s << "[FifoScheduler] " << fifo;
  66. }
  67.